const seeTodayNATMW = require('express').Router()
seeTodayNATMW.route('/wx')
    .post(async (req, res, next) => {
        if (req.jsonData.MsgType[0] == 'text') {
            const { jsonData } = req
            if (jsonData.Content[0].trim() == '当日抗原信息') {
                const mongoose = require('mongoose')
                const NAT = mongoose.model('nat', require('../../../model/nATSchema'))
                const data = await NAT.findOne({ userID: req.user.userID, date: require('../../../tools/getDate')('today') })
                if (data) {
                    // 发还图片
                    console.log(data)
                    const xmlSendData = require('../../../tools/sendPic')(jsonData.FromUserName[0], jsonData.ToUserName[0], data.picID)
                    res.end(xmlSendData)
                } else {
                    //无信息提示
                    const msg = '抱歉，暂时没有您的今日抗原信息'
                    const xmlSendData = require('../../../tools/sendMsg')(jsonData.FromUserName[0], jsonData.ToUserName[0], msg)
                    res.end(xmlSendData)
                }
            } else next()


        }
    })
module.exports = seeTodayNATMW